/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package main.Weighting;

import java.io.Serializable;

/**
 *
 * @author Isaac Osesina
 */
public class EvaluationParams implements Serializable{
    private double precision, recall;
    private double beta = 1;

    public EvaluationParams(double precision, double recall) {
        this.precision = precision;
        this.recall = recall;
    }

    public EvaluationParams() {
    }

    public double getfMeasure() {
        return calculateFMeasure();
    }

    public double getPrecision() {
        return precision;
    }

    public void setPrecision(double precision) {
        this.precision = precision;
    }

    public double getRecall() {
        return recall;
    }

    public void setRecall(double recall) {
        this.recall = recall;
    }

    private double calculateFMeasure() {
        double betaSquared = Math.pow(beta, 2);
        double num = (1+betaSquared) * precision * recall;
        double den = betaSquared * precision + recall;
        if(den==0) {
            return den;
        }
        return num/den;
    }

    public double calculateFMeasure(double beta) {
        this.beta = beta;
        return calculateFMeasure();
    }
}
